package com.system.controller;

import com.system.mapper.RoleMapper;
import com.system.po.Role;
import com.system.po.permission;
import com.system.po.role_permission;
import com.system.service.AssignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@Api(description = "权限分配")
@RequestMapping("assign")
@Controller
@ResponseBody
public class AssignController {

    @Autowired
    private AssignService assignService;



    @ApiOperation(value = "选择角色分配权限")
    @GetMapping("/findRoles")
    public List<Role> findRoles(){
        List<Role> roles = assignService.findRoles();
        return roles;
    }
    @ApiOperation(value = "分配哪些权限")
    @GetMapping("/Selectpermissions")
    public List<permission>Selectpermissions(){
       List<permission> Selectpermissions = assignService.Selectpermissions();
        return Selectpermissions;
    }




    @ApiOperation(value = "根据角色选择分配权限")
    @PostMapping("/distriBution/{id}")
    public  int adddistriBution(@PathVariable Integer id, @RequestBody List<permission> list) {
        return assignService.adddistriBution(id, list);


    }
}
